﻿Imports System.Net.Mail
Partial Class ForgotPwd
    Inherits System.Web.UI.Page

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        Dim GetPassword As New UserManagement
        Dim Password As String

        Password = GetPassword.RetrievePwd(Me.txtEmail.Text)

        Dim mailMsg As MailMessage = New MailMessage()

        If Password <> String.Empty Then
            mailMsg.From = New MailAddress("smfinlay@stevenfinlay.info")
            mailMsg.To.Add(New MailAddress(Me.txtEmail.Text))
            mailMsg.Subject = "StevenFinlay.info Password Request"
            mailMsg.Body = "Your Password is: " & Password

            Dim smptClient As SmtpClient = New SmtpClient()
            smptClient.Send(mailMsg)
            Response.Redirect("MailSent.aspx")
        Else
            errortext.Text = "Incorrect email, please try again"
        End If
    End Sub
End Class
